/**
 * Author@ Cheng Feitian
 * Date: 2021-3-25
 * Description: 类对象作为类成员
 */

#include <algorithm>
#include <iostream>
#include <string>

using namespace std;
const int maxn = 1024;

class Phone
{
private:
    
public:
    Phone(string name);
    ~Phone();
    string m_PName;
};

Phone::Phone(string name)
{
    m_PName = name;
    cout << "Phone的构造函数调用！" << endl;
}

Phone::~Phone()
{
    cout << "Phone类的析构函数调用" << endl;
}

class Person
{
private:
    
public:
    Person(string name,string pName);
    ~Person();
    string m_Name;
    Phone m_Phone;
};
//Phone m_Phone = pName;    隐式转换法
Person::Person(string name,string pName):m_Name(name),m_Phone(pName)
{
    cout << "Person的构造函数调用！" << endl;
}

Person::~Person()
{
    cout << "Person类的析构函数调用！" << endl;
}

//当其他类对象作为本类成员，构造时先构造类对象，在构造自身,析构顺序与构造相反

void test01(){
    Person p("张三","iphone 12 pro max");

    cout << p.m_Name << "拿着：" << p.m_Phone.m_PName << endl;
}

int main()
{
    test01();
    return 0;
}
